/**
 * For the license, see main.cpp file
 */

#ifndef MAINGUIIMPL_H
#define MAINGUIIMPL_H

#include <QWidget>
#include <QFont>
#include <QApplication>
#include <QString>
#include <QByteArray>
#include <QDebug>
#include <QMessageBox>
#include <QCloseEvent>
#include <QHideEvent>
#include <QDesktopWidget>
#include <QAction>
#include <QMenu>
#include <QSystemTrayIcon>
#include <QIcon>
#include <QList>
#include <QMapIterator>
#include <QListWidgetItem>
#include <QDesktopServices>

#include "ui_mainGui.h"
#include "FeedRSS.h"

class MainGuiImpl : public QWidget
{
	Q_OBJECT
	
private:
	QFont *logFont;
	QString endLine;
	QDesktopWidget *dw;		//for the screen geometry
	
	/* system tray stuff */
	QAction *minimizeAction;
	QAction *restoreAction;
	QAction *quitAction;	
	QAction *startStopAction;
	QSystemTrayIcon *trayIcon;
	QMenu *trayIconMenu;
	QIcon logoIconBig, logoIconSmall;
	
	/* feed rss context menu */
	//QMenu *itemContextMenu;
	//QAction *clipBoardAction;
	
	//void setNewsContextMenu();

private slots:
	void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
	
public:
	bool isSystemTray;
	Ui::Qrm3Form ui;
		
	MainGuiImpl();
	void fillRSSList(QList<QString> rssKeys);
	void setConnections();
	void createTrayIcon();
	void createActions();

protected:
	void closeEvent(QCloseEvent *event);
	void hideEvent (QHideEvent *event);

signals:
	void cronTimeSettingsChanged(unsigned int newTime);

public slots:
	void restoreDefaultSettings();
	void registerNewSettings();
	void startCronAuth();
	void startSingleAuth();
	void logLine(QString textToLog, bool showOnTray = false);
	void changeTrayIcon(bool connected);
	void renderNewsError(QString error);
	void renderNews(FeedRSS *news);
	void loadRss();
	void openNews(QListWidgetItem *item);
	void showUserIdentetyGui();
};

#endif // MAINGUIIMPL_H
